import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import singleSpaVue from "single-spa-vue";

Vue.config.productionTip = false;

// new Vue({
//   router,
//   render: h => h(App)
// }).$mount("#app");

const appOptions = {
  el: "#vue", // 挂载到父应用的id为vue的标签中
  router,
  render: h => h(App)
};

const vueLifeCycle = singleSpaVue({
  Vue,
  appOptions
});

// 如果是父应用引用我
if (window.singleSpaNavigate) {
  // 子应用却换已 public_path 为基准
  /* eslint-disable */
  __webpack_public_path__ = "http://localhost:10000/";
}
// 子应用自己启动
if (!window.singleSpaNavigate) {
  delete appOptions.el;
  new Vue(appOptions).$mount("#app");
}

// 协议接入， 定义好了协议 父应用会调用这些方法
export const bootstrap = vueLifeCycle.bootstrap;
export const mount = vueLifeCycle.mount;
export const unmount = vueLifeCycle.unmount;

// 我们需要父应用加载子应用，将子应用打包成一个个的lib去给父应用使用
